#pragma once
#ifndef Matrix_H
#define Matrix_H
#include <Windows.h>

class Matrix
{
public:
    Matrix& operator = (const Matrix& m);
    Matrix& operator = (const double a);
    friend bool operator == (const Matrix& m, const Matrix& n);

    virtual  void Alloc(double***& data, const int& height, const int& width);
    virtual  void Free(double***& data, const int& height ,const int& width);
    Matrix();
    Matrix(int h, int w);
    Matrix(int h, int w, double val);
    Matrix(const Matrix& m);
    virtual ~Matrix();

    void MeanFilter(int filterSize);
    void MedianFilter(int filterSize);

    friend void Swap(Matrix& a, Matrix& b);

    int Height()const;
    int Width()const;
    int Padding()const;
    int Cwidth(int w);

    void Transpose();

    double& At(int row, int col,int rgb);
    double& At(int row, int col,int rgb) const;
    void Set(int row, int col,int rgb ,double value);
    void Set(double value);
    void Normalize();
    Matrix& Normalize(int);
    void DisNormalize();

    void Reshape(int h, int w);
    bool IsEmpty() const;
    bool IsSquare() const;
    void CopyTo(Matrix& m);
    void Mult(double s);
    void Cat(Matrix& m, int code);

    friend void Swap(Matrix& a, Matrix& b);
protected:
    int height;
    int width;
    double*** data;
    int padding=0;
    int filterSize;
};

#endif
